import axios from 'axios'


const _axios = axios.create({
    // baseURL:'http://localhost:·8080',
    // 走代理
    withCredentials:true
});

 //拦截器
/* _axios.interceptors.request.use(
    function(config){
        //再次统一添加headers 后端添加token令牌
        config.headers = {
            Authorization : 'authorization'
        }
        return config;
    },
    function(error){
        Promise.reject(error);
    }
);*/
_axios.interceptors.request.use(
    function(config){
        //再次统一添加headers 后端添加token令牌
        config.headers = {
            Authorization : 'authorization'
        }
        return config;
    },
    function(error){
        Promise.reject(error);
    }
);

_axios.interceptors.response.use(
    // eslint-disable-next-line no-unused-vars
    function(response){
        //没有错误
    },
    function(error){
        if(error.response.status == 400){
            console.log();
            //不抛出异常 
            return Promise.resolve(400)
           
        }else if(error.response.status == 401){
            console.log();

            return Promise.resolve(401)
        }
        //类似抛出异常
        return Promise.reject(error);
    }
);

export default _axios;